package com.geekstudy.week11;


import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.BlockJUnit4ClassRunner;
import redis.clients.jedis.Jedis;

@RunWith(BlockJUnit4ClassRunner.class)
public class RedisStockServiceVerify {

    @Test
    public void testStock() {

        Jedis jedis = new Jedis("127.0.0.1", 6379);
        RedisStockService redisStockService = new RedisStockService(jedis);

        String product = "product202109";
        long reset1 = redisStockService.resetStock(product, 100l);
        System.out.println(" resetStock:" + reset1);

        long addStock1 = redisStockService.addStock(product, 20);
        System.out.println(" addStock:" + addStock1);

        long subtractStock1 = redisStockService.subtractStock(product, 50);
        System.out.println(" subtractStock1:" + subtractStock1);

        long subtractStock2 = redisStockService.subtractStock(product, 200);
        System.out.println(" subtractStock2:" + subtractStock2);






    }
}
